/**
 * Copyright 2013 Bhushan
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package org.s4j.signals.core;

import java.lang.reflect.Method;

/**
 * Contains the details of a slot. Primarily contains the object that has the slot and the method that has been declared
 * as slot
 * 
 * @author Bhushan
 * 
 */
public class SlotContainer implements Invocable {
    private String slotName;
    private Bridgeable object;
    private Method method;

    public SlotContainer() {
    }

    public SlotContainer(final Bridgeable obj, final String slotName, final Method method) {
        this.object = obj;
        this.method = method;
        this.setSlotName(slotName);
    }

    public Bridgeable getObject() {
        return object;
    }

    public void setObject(Bridgeable object) {
        this.object = object;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public String getSlotName() {
        return slotName;
    }

    public void setSlotName(String slotName) {
        this.slotName = slotName;
    }

    @Override
    public void accept(final InvocationVisitor visitor, final Object... parameters) {
        visitor.visit(this, parameters);
    }

    @Override
    public int hashCode() {
        return object.hashCode() | method.hashCode();
    }

    @Override
    public boolean equals(final Object obj) {
        if (obj == null)
            return false;
        if (obj instanceof SlotContainer) {
            // TODO: null checks need to be added
            return this.object.equals(((SlotContainer) obj).object) && this.method.equals(((SlotContainer) obj).method);
        }
        return false;
    }

}
